//
//  GKBookModel.swift
//  MySwiftObject
//
//  Created by wangws1990 on 2019/9/5.
//  Copyright © 2019 wangws1990. All rights reserved.
//

import UIKit
import HandyJSON
class GKBookModel:HandyJSON {
    var bookId:String!;
    var updateTime:String!;
    var author:String!;
    var cover:String!;
    var shortIntro :String!
    var title:String!;
    var site:String!;
    var majorCate:String!;
    var minorCate:String!;
    var allowMonthly :String!
    
    var contentType:String!;
    var lastChapter:String!;
    var superscript :String!
    
    var retentionRatio :Float!;
    var latelyFollower :Int!;
    var banned :Int!;
    
    func getCovers()->String{
        var url:String = self.cover;
        if self.cover.hasPrefix("/agent/") {
          url =  self.cover.replacingOccurrences(of: "/agent/", with: "");
        }
        return url.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!
    }
    required init() {}
    
    func mapping(mapper: HelpingMapper) {
        mapper <<<
            self.bookId <-- "_id"
        mapper <<<
            self.shortIntro <-- ["longIntro","shortIntro"]
    }
  
}
